package org.crud4j.core.test;

import java.util.Date;

import org.crud4j.core.annotation.CrudBean;
import org.crud4j.core.annotation.CrudFieldEditor;
import org.crud4j.core.annotation.CrudForeignKey;
import org.crud4j.core.annotation.CrudHidden;
import org.crud4j.core.annotation.CrudId;
import org.crud4j.core.annotation.CrudIdClass;
import org.crud4j.core.annotation.CrudLength;
import org.crud4j.core.annotation.CrudNewDisabled;
import org.crud4j.core.annotation.CrudNullable;
import org.crud4j.core.annotation.CrudRemoveDisabled;
import org.crud4j.core.annotation.CrudRespectEmptyValue;
import org.crud4j.core.annotation.CrudValidation;
import org.crud4j.core.annotation.FieldEditor;

/**
 * in the tests courses are stored in another persistence storage and
 * relationships are not modelled with complex objects but only with the
 * respective ids, as in the old days before hibernate
 */
@CrudBean
// it should contain a compound pk. I use String just for test, but it's not a
// valid argument.
@CrudIdClass(String.class)
@CrudNewDisabled
@CrudRemoveDisabled
public class Course {

	private String id;

	private String name;

	private Boolean mandatory;

	private Date startDate;

	private String teacherId;

	private Integer length;

	@CrudId
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@CrudFieldEditor(FieldEditor.DEFAULT)
	@CrudRespectEmptyValue
	@CrudValidation(regexp = "course-[0-9]")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@CrudNullable(false)
	public Boolean getMandatory() {
		return mandatory;
	}

	public void setMandatory(Boolean mandatory) {
		this.mandatory = mandatory;
	}

	@CrudHidden
	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	@CrudForeignKey(Teacher.class)
	public String getTeacherId() {
		return teacherId;
	}

	public void setTeacherId(String teacherId) {
		this.teacherId = teacherId;
	}

	@CrudLength(30)
	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

}
